<template>
  <div class="app-container">
    <el-table v-loading="loading" :data="withdrawalsList">
      <el-table-column label="用户名" align="center" prop="userName" width="120" :show-overflow-tooltip="true">
        <template slot-scope="scope">
          <span style="vertical-align: middle;margin-right: 8px">
            <oss-image-preview v-if="scope.row.avatar" :src="scope.row.avatar" :width="30" :height="30" :model="'text'" :name="scope.row.userName"/>
            <span v-else>{{ scope.row.userName }}</span>
          </span>
        </template>
      </el-table-column>
      <el-table-column label="申请金额" align="center" prop="amount" width="160" :show-overflow-tooltip="true" :formatter="formatterAmount"/>
      <el-table-column label="申请人" align="center" prop="rechargeName" width="160" :show-overflow-tooltip="true"/>
      <el-table-column label="银行名称" align="center" prop="bankName" width="160" :show-overflow-tooltip="true"/>
      <el-table-column label="银行卡号" align="center" prop="bankNo" width="300" :show-overflow-tooltip="true"/>
      <el-table-column label="邮箱" align="center" prop="email" width="160" :show-overflow-tooltip="true"/>
      <!-- <el-table-column label="汇率国家名称" align="center" prop="exchangeRateName" width="120" :show-overflow-tooltip="true" />
      <el-table-column label="汇率国家缩写" align="center" prop="country" width="120" :show-overflow-tooltip="true" />
      <el-table-column label="汇率金额" align="center" prop="rateAmount" width="120" :show-overflow-tooltip="true" /> -->
<!--      <el-table-column label="汇率" align="center" prop="exchangeRate" width="120" :show-overflow-tooltip="true"/>-->
      <el-table-column label="打款方式" align="center" prop="paymentMethod" width="160" :show-overflow-tooltip="true">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.payment_method" :value="scope.row.paymentMethod" />
        </template>
      </el-table-column>
      <el-table-column label="申请时间" align="center" prop="createTime" width="220" :show-overflow-tooltip="true">
        <template slot-scope="scope">
          <span>{{ parseTime(scope.row.createTime, '{m}/{d}/{y}') }}</span>
        </template>
      </el-table-column>
      <el-table-column label="状态" align="center" prop="auditType" width="140" :show-overflow-tooltip="true">
        <template slot-scope="scope">
          <dict-tag :options="dict.type.recharge_withdraw_status" :value="scope.row.auditType" />
        </template>
      </el-table-column>
    </el-table>

    <pagination v-show="total > 0" :total="total" :page.sync="queryParams.pageNum" :limit.sync="queryParams.pageSize"
                @pagination="getList" />

  </div>
</template>

<script>
import {
  addWithdrawals,
  auditWithdrawals,
  delWithdrawals,
  getWithdrawals,
  listWithdrawals,
  updateWithdrawals
} from "@/api/user/withdrawals";
import DictSelect from "@/components/DictSelect/index.vue";
import DateRangePicker from "@/components/DateRangePicker/index.vue";
import OssImagePreview from "@/components/ImagePreview/oss-image-preview.vue";
import Template from '@/views/setting/template/index.vue'
export default {
  name: "Withdrawals",
  components: { Template, DateRangePicker, DictSelect ,OssImagePreview},
  dicts: ['payment_method', 'recharge_withdraw_status'],
  data() {
    return {
      // 遮罩层
      loading: true,
      // 选中数组
      ids: [],
      // 显示搜索条件
      showSearch: true,
      // 总条数
      total: 0,
      // 用户充值表格数据
      withdrawalsList: [],
      // 查询参数
      queryParams: {
        pageNum: 1,
        pageSize: 10,
        auditTypes:[1,2],
        userId:null,
      },
      dateRange: [],
    };
  },
  created() {
    if (this.$route.query.id){
      this.queryParams.userId = this.$route.query.id;
    }
    this.getList();
  },
  methods: {
    /** 查询用户充值列表 */
    getList() {
      this.loading = true;
      listWithdrawals({ ...this.queryParams })
        .then(response => {
          this.withdrawalsList = response.data.records;
          this.total = response.data.total;
          this.loading = false;
        });
    },
    formatterAmount:function(row){
      return this.$yun.priceFormatter(row.amount);
    },
  },
};
</script>
